package com.xu.controller;

import com.xu.pojo.Movie;
import com.xu.service.MovieService;
import com.xu.uitls.DateUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import java.util.Date;
import java.util.List;

@Controller
public class MovieController {
    @Autowired
    MovieService movieService;

    @RequestMapping(value = "/")
    public String queryMovies(Model model){
        String date = DateUtil.gainTime(new Date(new Date().getTime() - 1000 * 60 * 60 * 24));

        List<Movie> movieList = movieService.queryMovies(date);

        System.out.println(movieList);
        model.addAttribute("movieList",movieList);

        return "movie";
    }
}
